package com.example.sql.manager.validator;

import com.example.sql.manager.entity.po.FuncPO;
import com.example.sql.manager.enums.Enabled;
import com.example.sql.manager.enums.SQLType;
import org.springframework.util.Assert;

public class FuncValidator {

    public static void validate(FuncPO func) {
        Assert.hasText(func.getTitle(), "[Assertion failed] - title must not be null");
        Assert.hasText(func.getContent(), "[Assertion failed] - content must not be null");
        Assert.hasText(func.getDescription(), "[Assertion failed] - description must not be null");

        Assert.notNull(func.getEnabled(), "[Assertion failed] - enabled must not be null");
        Assert.state(Enabled.getValues().contains(func.getEnabled()), "[Assertion failed] - enabled is error");

        Assert.notNull(func.getSqlType(), "[Assertion failed] - sqlType must not be null");
        Assert.state(SQLType.getValues().contains(func.getSqlType()), "[Assertion failed] - sqlType is error");
    }

}
